/**
 * 
 */
package com.mes.check.domain;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.context.annotation.Lazy;

import com.mes.basicdata.domain.Dept;
import com.mes.basicdata.domain.Employee;
import com.mes.basicdata.domain.TypesData;
import com.mes.common.domain.BasicModel;
import com.mes.task.domain.OperationTask;

/**
 * <p>
 * 让步单明细
 * </p>
 */
@Entity()
@Table(name = "M_REWORKHEADER")
@BatchSize(size = 20)
@Lazy(value = true)
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Rework extends BasicModel implements java.io.Serializable {

	public static final int REWORK_BILLSTATE_CREATED = 0; //　已创建
	public static final int REWORK_BILLSTATE_UNCLOSED = 9; // 未结案
	public static final int REWORK_BILLSTATE_CLOSED = 10; // 已结案
	
	/**
	 * 复杂对象映射--defectJudge defectJudge
	 */
	@Id
	@GenericGenerator(name = "uniqueId", strategy = "assigned")
	@Column(name = "REWORKUID")
	protected String uniqueId;

	@Column(name = "REWORKID")
	protected String reworkId;

	@Column(name = "DEFECTJUDGEUID")
	protected String defectJudgeUid;

	@ForeignKey(name = "null")
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "DEFECTJUDGEUID", insertable = false, updatable = false)
	protected DefectJudge defectJudge;

	@Column(name = "TASKUID")
	protected String taskUid;

	@ForeignKey(name = "null")
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "TASKUID", insertable = false, updatable = false)
	protected OperationTask operationTask;

	@Column(name = "DEPTID")
	protected String deptUid;

	@ForeignKey(name = "null")
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "DEPTID", insertable = false, updatable = false)
	protected Dept dept;

	@Column(name = "RWSTATE")
	protected Integer reworkState;

	@Column(name = "SUBMITQTY")
	protected Float submitQty;

	@Column(name = "REWORKQTY")
	protected Float reworkQty;

//	// 责任者
//	@Column(name = "DUTIER")
//	protected String dutierUid;
//	@ForeignKey(name = "null")
//	@ManyToOne(fetch = FetchType.LAZY)
//	@JoinColumn(name = "DUTIER", insertable = false, updatable = false)
//	protected Employee dutier;

	// 检验室主任
	@Column(name = "CHECKMANAGER")
	protected String checkManagerUid;

	@ForeignKey(name = "null")
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "CHECKMANAGER", insertable = false, updatable = false)
	protected Employee checkManager;

	@Column(name = "DEFECTREASON")
	protected String defectReason;

	// 检验员
	@Column(name = "CHECKER")
	protected String checkerUid;

	@ForeignKey(name = "null")
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "CHECKER", insertable = false, updatable = false)
	protected Employee checker;

	@Column(name = "CHECKTIME")
	protected Date checkTime;

	// 损失工时
	@Column(name = "RWHOUR")
	protected Float reworkHour;

	// 损失金额
	@Column(name = "RWMONEY")
	protected Float reworkMoney;

//	// 工段长
//	@Column(name = "SEGEMENTMANAGER")
//	protected String segementManagerUid;
//	@ForeignKey(name = "null")
//	@ManyToOne(fetch = FetchType.LAZY)
//	@JoinColumn(name = "SEGEMENTMANAGER", insertable = false, updatable = false)
//	protected Employee segementManager;

	@Column(name = "ISINBULK")
	protected Boolean isInBulk;

	@Column(name = "ATTATCHREF")
	protected String attatchRef;

//	// 工艺员
//	@Column(name = "ROUTIER")
//	protected String routierUid;
//
//	@ForeignKey(name = "null")
//	@ManyToOne(fetch = FetchType.LAZY)
//	@JoinColumn(name = "ROUTIER", insertable = false, updatable = false)
//	protected Employee routier;

	@Column(name = "REWORKSTATE")
	protected Integer reworkBillState;

	@Column(name = "ISINEFFECT")
	protected Boolean isInEffect;

//	// 批复状态
//	@Column(name = "APPROVESTATE")
//	protected Integer approveState;
//
//	// 批复人员
//	@Column(name = "APPROVEPERSON")
//	protected String approvePersonUid;
//
//	@ForeignKey(name = "null")
//	@ManyToOne(fetch = FetchType.LAZY)
//	@JoinColumn(name = "APPROVEPERSON", insertable = false, updatable = false)
//	protected Employee approvePerson;

	@Column(name = "BILLNUMBER")
	protected String billNumber;

	@Column(name = "MATERIALUSN")
	protected String materialUid;

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "rework")
	public List<ReworkDetail> reworkDetails;
	
	
	// Constructors

	/** default constructor */
	public Rework() {
	}

	/**
	 * 获取不合格品审理编号。
	 * 
	 * @return the defectJudgeUid
	 */

	public String getdefectJudgeUid() {
		return defectJudgeUid;
	}

	/**
	 * 设置不合格品审理编号。
	 * 
	 * @param defectJudgeUid
	 *            the defectJudgeUid to set
	 */
	public void setdefectJudgeUid(String defectJudgeUid) {
		this.defectJudgeUid = defectJudgeUid;
	}

	/**
	 * 获取不合格品审理单表头。
	 * 
	 * @return the defectJudge
	 */

	public DefectJudge getdefectJudge() {
		return defectJudge;
	}

	/**
	 * 设置不合格品审理单表头。
	 * 
	 * @param defectJudge
	 *            the defectJudge to set
	 */
	public void setDefectJudge(DefectJudge defectJudge) {
		this.defectJudge = defectJudge;
	}

	/**
	 * 获取返工编号。
	 * 
	 * @return the reworkId
	 */

	public String getReworkId() {
		return reworkId;
	}

	/**
	 * 设置返工编号。
	 * 
	 * @param reworkId
	 *            the reworkId to set
	 */
	public void setReworkId(String reworkId) {
		this.reworkId = reworkId;
	}

	/**
	 * 获取任务编号。
	 * 
	 * @return the taskUid
	 */

	public String getTaskUid() {
		return taskUid;
	}

	/**
	 * 设置任务编号。
	 * 
	 * @param taskUid
	 *            the taskUid to set
	 */
	public void setTaskUid(String taskUid) {
		this.taskUid = taskUid;
	}

	/**
	 * 获取部门编号。
	 * 
	 * @return the deptUid
	 */

	public String getDeptUid() {
		return deptUid;
	}

	/**
	 * 设置部门编号。
	 * 
	 * @param deptUid
	 *            the deptUid to set
	 */
	public void setDeptUid(String deptUid) {
		this.deptUid = deptUid;
	}

	/**
	 * 获取部门。
	 * 
	 * @return the dept
	 */

	public Dept getDept() {
		return dept;
	}

	/**
	 * 设置部门。
	 * 
	 * @param dept
	 *            the dept to set
	 */
	public void setDept(Dept dept) {
		this.dept = dept;
	}

	/**
	 * 获取返工状态。
	 * 
	 * @return the reworkState
	 */

	public Integer getReworkState() {
		return reworkState;
	}

	/**
	 * 设置返工状态。
	 * 
	 * @param reworkState
	 *            the reworkState to set
	 */
	public void setReworkState(Integer reworkState) {
		this.reworkState = reworkState;
	}

	/**
	 * 获取提交数量。
	 * 
	 * @return the submitQty
	 */

	public Float getSubmitQty() {
		return submitQty;
	}

	/**
	 * 设置提交数量。
	 * 
	 * @param submitQty
	 *            the submitQty to set
	 */
	public void setSubmitQty(Float submitQty) {
		this.submitQty = submitQty;
	}

	/**
	 * 获取返工数量。
	 * 
	 * @return the reworkQty
	 */

	public Float getReworkQty() {
		return reworkQty;
	}

	/**
	 * 设置返工数量。
	 * 
	 * @param reworkQty
	 *            the reworkQty to set
	 */
	public void setReworkQty(Float reworkQty) {
		this.reworkQty = reworkQty;
	}

	/**
	 * 获取检验管理员编号。
	 * 
	 * @return the checkManagerUid
	 */

	public String getCheckManagerUid() {
		return checkManagerUid;
	}

	/**
	 * 设置检验管理员编号。
	 * 
	 * @param checkManagerUid
	 *            the checkManagerUid to set
	 */
	public void setCheckManagerUid(String checkManagerUid) {
		this.checkManagerUid = checkManagerUid;
	}

	/**
	 * 获取检验管理员。
	 * 
	 * @return the checkManager
	 */

	public Employee getCheckManager() {
		return checkManager;
	}

	/**
	 * 设置检验管理员。
	 * 
	 * @param checkManager
	 *            the checkManager to set
	 */
	public void setCheckManager(Employee checkManager) {
		this.checkManager = checkManager;
	}

	/**
	 * 获取不合格原因。
	 * 
	 * @return the defectReason
	 */

	public String getDefectReason() {
		return defectReason;
	}

	/**
	 * 设置不合格原因。
	 * 
	 * @param defectReason
	 *            the defectReason to set
	 */
	public void setDefectReason(String defectReason) {
		this.defectReason = defectReason;
	}

	/**
	 * 获取检验员编号。
	 * 
	 * @return the checkerUid
	 */

	public String getCheckerUid() {
		return checkerUid;
	}

	/**
	 * 设置检验员编号。
	 * 
	 * @param checkerUid
	 *            the checkerUid to set
	 */
	public void setCheckerUid(String checkerUid) {
		this.checkerUid = checkerUid;
	}

	/**
	 * 获取检验员。
	 * 
	 * @return the checker
	 */

	public Employee getChecker() {
		return checker;
	}

	/**
	 * 设置检验员。
	 * 
	 * @param checker
	 *            the checker to set
	 */
	public void setChecker(Employee checker) {
		this.checker = checker;
	}

	/**
	 * 获取检验时间。
	 * 
	 * @return the checkTime
	 */

	public Date getCheckTime() {
		return checkTime;
	}

	/**
	 * 设置检验时间。
	 * 
	 * @param checkTime
	 *            the checkTime to set
	 */
	public void setCheckTime(Date checkTime) {
		this.checkTime = checkTime;
	}

	/**
	 * 获取返工时间。
	 * 
	 * @return the reworkHour
	 */

	public Float getReworkHour() {
		return reworkHour;
	}

	/**
	 * 设置返工时间。
	 * 
	 * @param reworkHour
	 *            the reworkHour to set
	 */
	public void setReworkHour(Float reworkHour) {
		this.reworkHour = reworkHour;
	}

	/**
	 * 获取返工金额。
	 * 
	 * @return the reworkMoney
	 */

	public Float getReworkMoney() {
		return reworkMoney;
	}

	/**
	 * 设置返工金额。
	 * 
	 * @param reworkMoney
	 *            the reworkMoney to set
	 */
	public void setReworkMoney(Float reworkMoney) {
		this.reworkMoney = reworkMoney;
	}

	/**
	 * 获取是否成批。
	 * 
	 * @return the isInBulk
	 */

	public Boolean getIsInBulk() {
		return isInBulk;
	}

	/**
	 * 设置是否成批。
	 * 
	 * @param isInBulk
	 *            the isInBulk to set
	 */
	public void setIsInBulk(Boolean isInBulk) {
		this.isInBulk = isInBulk;
	}

	/**
	 * 获取相关文档。
	 * 
	 * @return the attatchRef
	 */

	public String getAttatchRef() {
		return attatchRef;
	}

	/**
	 * 设置相关文档。
	 * 
	 * @param attatchRef
	 *            the attatchRef to set
	 */
	public void setAttatchRef(String attatchRef) {
		this.attatchRef = attatchRef;
	}

	/**
	 * 获取表单号。
	 * 
	 * @return the billNumber
	 */

	public String getBillNumber() {
		return billNumber;
	}

	/**
	 * 设置表单号。
	 * 
	 * @param billNumber
	 *            the billNumber to set
	 */
	public void setBillNumber(String billNumber) {
		this.billNumber = billNumber;
	}

	/**
	 * 获取物料编号。
	 * 
	 * @return the materialUid
	 */

	public String getMaterialUid() {
		return materialUid;
	}

	/**
	 * 设置物料编号。
	 * 
	 * @param materialUid
	 *            the materialUid to set
	 */
	public void setMaterialUid(String materialUid) {
		this.materialUid = materialUid;
	}

	/**
	 * 获取任务操作。
	 * 
	 * @return the operationTask
	 */

	public OperationTask getOperationTask() {
		return operationTask;
	}

	/**
	 * 设置任务操作。
	 * 
	 * @param operationTask
	 *            the operationTask to set
	 */
	public void setOperationTask(OperationTask operationTask) {
		this.operationTask = operationTask;
	}

	/**
	 * 获取是否有效（默认为0）。
	 * 
	 * @return the isInEffect
	 */

	public Boolean getIsInEffect() {
		return isInEffect;
	}

	/**
	 * 设置是否有效状态（默认为1）。
	 * 
	 * @param isInEffect
	 *            the isInEffect to set
	 */
	public void setIsInEffect(Boolean isInEffect) {
		this.isInEffect = isInEffect;
	}
}
